package users

import (
	"goskeleton/app/global/consts"
	"goskeleton/app/http/controller/web"
	"goskeleton/app/http/validator/core/data_transfer"
	"goskeleton/app/utils/response"

	"github.com/gin-gonic/gin"
)

// UserPermissions 获取用户权限验证器
type UserPermissions struct {
	UserId float64 `form:"user_id" json:"user_id" binding:"required,min=1"`
}

func (p UserPermissions) CheckParams(context *gin.Context) {
	if err := context.ShouldBind(&p); err != nil {
		response.ValidatorError(context, err)
		return
	}

	extraAddBindDataContext := data_transfer.DataAddContext(p, consts.ValidatorPrefix, context)
	if extraAddBindDataContext == nil {
		response.ErrorSystem(context, "UserPermissions表单验证器json化失败", "")
	} else {
		(&web.Users{}).GetUserPermissions(extraAddBindDataContext)
	}
}
